<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="注册时间">
        <el-date-picker
          v-model="formInline.time"
          type="daterange"
          align="right"
          unlink-panels
          :picker-options="pickerDayStep"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss">
        </el-date-picker>
      </el-form-item>
      <el-form-item class="with-pre-select" prop="keywords">
        <el-input placeholder="请输入关键词" v-model="formInline.keywords" class="input-with-select" @keyup.enter.native="$emit('on-filter',formInline)">
          <el-select v-model="formInline.searchType" slot="prepend" placeholder="请选择查询范围">
            <el-option label="账号名" :value="1"></el-option>
            <el-option label="姓名" :value="2"></el-option>
          </el-select>
          <!--<el-button slot="append" icon="el-icon-search"></el-button>-->
        </el-input>
      </el-form-item>
      <el-form-item label="审核人" prop="operator">
        <el-select v-model="formInline.operator">
          <el-option
            :label="'全部'"
            :key="consts.ALL"
            :value="undefined"
          ></el-option>
          <el-option
            v-for="item in auditorList"
            v-if="!!item"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择审核状态">
          <el-option
            v-for="item in consts.AUDIT_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {getAgencyAuditorList} from '@/services/api/agency'
  import {form, grid, pickerOption} from '@/build'

  export default {
    name: "form-filter",
    mixins: [form, grid, pickerOption],
    data() {
      return {
        auditorList: [],
        auditFirList: [],
        stepFir: {step: 1},
        stepSec: {step: 2},
        auditSecList: [],
        formInline: {
          time: [
            moment().format('YYYY-MM-DD 00:00:00'),
            moment().format('YYYY-MM-DD 23:59:59'),
          ],
          keywords: undefined,
          searchType: 1,
          model: undefined,
          status: -1,
          operator: undefined
        },
      }
    },
    methods: {
      selfResetForm(formName) {
        this.resetForm(formName)
        this.$parent.getAll()
      }
    },
    mounted() {
      this.bindGet(getAgencyAuditorList, 'auditorList', {
        action: 'getGrid',
        sendingData: 'filters'
      })
      this.getAll()
    }
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
